Skip to content

feat: price alert percentage feature#33339

Open
bergarces wants to merge 18 commits into
mainfrom
price-alerts-price-percent
Open

feat: price alert percentage feature#33339
bergarces wants to merge 18 commits into
mainfrom
price-alerts-price-percent

Conversation

@bergarces

@bergarces bergarces commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Description

Adds percent-change price alerts so users can get notified when a token moves up or down by a chosen percentage over a rolling 1h or 24h window, alongside existing absolute price-target alerts.

The create screen is refactored into a thin shell with an alert-type toggle (Price target / Price change) and dedicated forms (AbsolutePriceAlertForm, PercentChangeAlertForm). Shared save behavior lives in useAlertSaveFlow. Manage alerts lists both types, and the API layer adds /v1/alerts/percent-change CRUD with alert-type routing and backward-compatible normalization (alerts missing type default to absolute_price).

Changelog

CHANGELOG entry: Added percent-change price alerts so users can be notified when a token moves up or down by a set percentage over 1 hour or 24 hours

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/ASSETS-3593

Manual testing steps

Feature: Percent-change price alerts

  Scenario: user creates a percent-change alert
    Given the user is signed in and price alerts are available for a token
    And the user opens Create price alert for that token
    When the user selects "Price change"
    And chooses direction (up or down), period (1hr or 24hr), and a percent threshold
    And optionally enables Recurring
    And taps Set price alert
    Then the alert is saved successfully
    And the alert appears in Manage price alerts with the correct percent summary

  Scenario: user creates an absolute price-target alert
    Given the user is on Create price alert for a token
    When the user leaves "Price target" selected
    And enters a target price (or uses a quick % pill)
    And taps Set price alert
    Then the absolute price alert is saved successfully
    And existing absolute-target behavior still works (including duplicate threshold messaging)

  Scenario: user cannot switch alert type while editing
    Given the user opens an existing alert in edit mode
    When the create/edit screen is shown
    Then the alert type toggle is locked to the alert's existing type
    And the user can update that alert's fields and save

  Scenario: user manages mixed alert types
    Given the user has both price-target and percent-change alerts for a token
    When the user opens Manage price alerts
    Then both alert types are listed with the correct titles and subtitles
    And the user can toggle, edit, and delete each type

Screenshots/Recordings

Before

N/A — percent-change alerts were not available (Price change was under development / placeholder). Absolute price-target create/manage unchanged in concept; attach prior screenshots if useful for comparison.

After

Simulator.Screen.Recording.-.iPhone.16.Pro.-.2026-07-15.at.15.57.34.mov

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

For performance guidelines and tooling, see the Performance Guide.

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Note

Medium Risk
New authenticated API surface and a large UI refactor around alert creation and management, though behavior is heavily tested and legacy absolute alerts remain backward compatible via normalization.

Overview
Adds percent-change price alerts (up/down % over 1h or 24h) next to existing absolute price target alerts, replacing the prior “under development” placeholder.

Create flow is split into a thin CreatePriceAlertView with a Price target / Price change toggle (AlertTypeToggle) and two forms: AbsolutePriceAlertForm (moved keypad, quick % pills, duplicate-by-threshold) and new PercentChangeAlertForm (direction, period, % keypad, duplicate-by configuration tuple). Shared UI (AlertFormShell, AlertAmountInput, RecurringToggle, sliding pill toggles) and useAlertSaveFlow centralize submit, cache patch, analytics, toasts, and navigation. Route params shift from existingThresholds to existingAbsoluteAlerts / existingPercentAlerts; edit mode locks alert type.

API gains /v1/alerts/percent-change CRUD, useSubmitPercentAlert, updateAlertByType / deleteAlertByType, normalizeAlerts (missing typeabsolute_price), and shared assertOkResponse. Manage lists both types with formatted percent rows, passes split existing alerts when adding/editing, and emits percent-specific analytics on toggle/delete.

Broad unit and component-view test coverage accompanies the refactor.

Reviewed by Cursor Bugbot for commit 577baf8. Bugbot is set up for automated code reviews on this repo. Configure here.

@bergarces bergarces requested a review from a team as a code owner July 15, 2026 12:15
@github-actions

Copy link
Copy Markdown
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamask-ci

metamask-ci Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

PR template — items to address before "Ready for review"

Warnings — informational, address before merging:

  • Pre-merge author checklist has unchecked items (e.g. "I've tested on Android"). Every box must be consciously checked — see docs/readme/ready-for-review.md.

See docs/readme/ready-for-review.md for the full Definition of Ready for Review.

@github-actions github-actions Bot added size-XL risk:low AI analysis: low risk labels Jul 15, 2026
@bergarces bergarces changed the title new price percent feature feat: price alert percentage feature Jul 15, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 9f071af. Configure here.

@bergarces bergarces requested a review from a team as a code owner July 15, 2026 13:11
@github-actions github-actions Bot added risk:medium AI analysis: medium risk and removed risk:low AI analysis: low risk labels Jul 15, 2026
@bergarces bergarces force-pushed the price-alerts-price-percent branch from a183fc3 to bd02f31 Compare July 15, 2026 15:19

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a common component to handle the input for both threshold and percent (the percent has a prefix and suffix).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropped most of the code here and created new components for each alert type.

@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: None (no tests recommended)
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: low
  • AI Confidence: 92%
click to see 🤖 AI reasoning details

E2E Test Selection:
The PR changes are entirely contained within the PriceAlerts feature area (app/components/UI/Assets/PriceAlerts/). Key findings:

  1. No E2E smoke tests exist for PriceAlerts: Exhaustive search of tests/smoke//* and tests//* found zero references to PriceAlert, priceAlert, or price_alert. There are no smoke specs to run or validate.

  2. Component-view test mock only: The critical file (tests/component-view/api-mocking/priceAlerts.ts) is a Jest/nock mock for component-view tests — not E2E smoke infrastructure. It doesn't affect any smoke test execution pipeline.

  3. Self-contained feature changes: The changes add percent_change alert type support (new API endpoints, new form components, new hooks), refactor the useSubmitPriceAlert hook, and add localization strings. These are all within the PriceAlerts module.

  4. No shared infrastructure impact: The changes don't touch Engine, controllers, navigation (beyond being a registered route in MainNavigator.js), shared modals, or any component that existing smoke tests depend on.

  5. Localization changes: The en.json changes add new price alert strings and rename one existing string ("price_reaches" → "price_target"). This is isolated to the price_alerts namespace and won't affect any existing E2E test flows.

  6. No performance-sensitive paths: PriceAlerts is a secondary feature screen (not in the critical app launch, login, or asset loading paths), so no performance tests are warranted.

Since there are no existing E2E smoke tests covering PriceAlerts and the changes don't affect any shared components that other smoke tests rely on, running zero E2E tags is the correct and efficient choice.

Performance Test Selection:
The PriceAlerts feature is a secondary screen for managing price notifications. Changes are to form components, API hooks, and localization strings. None of these touch performance-sensitive paths like app launch, login, onboarding, asset loading, or swap flows. No performance test tags are warranted.

View GitHub Actions results

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.60403% with 28 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.41%. Comparing base (c4cb337) to head (577baf8).
⚠️ Report is 63 commits behind head on main.

Files with missing lines Patch % Lines
...ssets/PriceAlerts/components/SlidingPillToggle.tsx 72.41% 5 Missing and 3 partials ⚠️
...ts/PriceAlerts/Views/CreatePriceAlertView/utils.ts 71.42% 1 Missing and 5 partials ⚠️
...ws/ManagePriceAlertsView/ManagePriceAlertsView.tsx 79.31% 0 Missing and 6 partials ⚠️
...ws/CreatePriceAlertView/AbsolutePriceAlertForm.tsx 92.45% 0 Missing and 4 partials ⚠️
...ws/CreatePriceAlertView/PercentChangeAlertForm.tsx 92.50% 0 Missing and 3 partials ⚠️
...ts/UI/Assets/PriceAlerts/hooks/useAlertSaveFlow.ts 96.55% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #33339      +/-   ##
==========================================
+ Coverage   84.37%   84.41%   +0.04%     
==========================================
  Files        6127     6147      +20     
  Lines      163530   163990     +460     
  Branches    39887    40048     +161     
==========================================
+ Hits       137974   138437     +463     
- Misses      16050    16053       +3     
+ Partials     9506     9500       -6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants